# -*- coding: utf-8 -*-
#
# SConscript for building the MahJong-Night automated tests.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 3 of the License.
#
# Author: VestniK (Sergey N.Vidyuk) sir.vestnik@gmail.com
# Date: 18 Jun 2009
#
from get_files import *

Import('BaseEnv SrvLib ClientLib')
guiLib = BaseEnv['GUI_LIB']
DirList = ['Combinations','Wall','Game','Server','TileSet','Session','ObjLoader']

tests = BaseEnv.Clone()

tests.Append(CPPPATH = DirList)
tests.Append(CPPPATH = 'TestsCommon')
tests.Append(CPPPATH = '#services')
tests.Append(CPPPATH = '#server')
tests.Append(CPPPATH = '#client')
tests.Append(CPPPATH = '#client/common')
tests.Append(CPPPATH = '#client/gui')
tests.Append(LIBPATH = '.')
tests.Prepend(LIBS = [guiLib,ClientLib,SrvLib])
tests.EnableQt4Modules(['QtCore','QtGui','QtNetwork','QtXml','QtOpenGL','QtTest'])
tests['BUILDERS']['QTest'] = Builder(action='$SOURCE -xml -o $TARGET',
                                     src_suffix='',
                                     suffix='.report.xml')

for tstdir in DirList:
    TestSources = get_files_list(tstdir,'\.cpp$',['moc_.*\.cpp$'])
    test = tests.Program("Test"+tstdir , TestSources)
    if 'test' in COMMAND_LINE_TARGETS:
        Alias('test', tests.AlwaysBuild(tests.QTest(test)) )